Skip to content

LibWeb: Fix NodeIterator retargeting during removals #10404

Merged
shannonbooth merged 2 commits into
LadybirdBrowser:masterfrom
shannonbooth:node-iterator-align-with-spec
Jul 3, 2026
Merged

LibWeb: Fix NodeIterator retargeting during removals #10404
shannonbooth merged 2 commits into
LadybirdBrowser:masterfrom
shannonbooth:node-iterator-align-with-spec

Conversation

@shannonbooth

Copy link
Copy Markdown
Member

Align NodeIterator with the current DOM spec traversal and pre-removal
algorithms. The spec now covers the cases we were previously working
around to match the behaviour of other engines. The algorithm we had
implemented to protect against removal during filtering matches
the spec algorithm quite closely, with slightly different factoring.

See:

This fixes the case where removing an ancestor of the reference or
candidate reference, with the pointer before it and no following
node inside the root, should retarget to the previous in-tree node
instead of leaving the iterator on a detached node.

Align NodeIterator with the current DOM spec traversal and pre-removal
algorithms. The spec now covers the cases we were previously working
around to match the behaviour of other engines. The algorithm we had
implemented to protect against removal during filtering matches
the spec algorithm quite closely, with slightly different factoring.

See:
 * whatwg/dom#1479
 * whatwg/dom#1477

This fixes the case where removing an ancestor of the reference or
candidate reference, with the pointer before it and no following
node inside the root, should retarget to the previous in-tree node
instead of leaving the iterator on a detached node.
@shannonbooth
shannonbooth merged commit 97053be into LadybirdBrowser:master Jul 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant